package com.XinYun.Library.modules.borrow;

import com.XinYun.Library.modules.borrow.Service.Service;
import com.XinYun.Library.modules.borrow.Service.ServiceImpl;
import com.XinYun.Library.utils.HTTPRequestUtils.HTTPRequestUtil;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "borrowServlet", value = "/borrowServlet")
public class borrowServlet extends HttpServlet {
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String json = HTTPRequestUtil.getBody(request);
        //将JSON字符转化为JAVA对象
        System.out.println(request.getContextPath());
        JSONObject jsonObject = JSONObject.parseObject(json);
        String value = jsonObject.getString("bid");
        Service service = new ServiceImpl();
        service.State0(value);
            jsonObject.put("code",1);
            jsonObject.put("message","借书成功");
        response.getWriter().write(jsonObject.toString());
    }
}
